home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / emstools.arc / EMMLIB.ARC / EMM25_A.ASM < prev    next >
Assembly Source File  |  1990-02-04  |  58KB  |  1,053 lines

  1. ;-----------------------------------------------------------------------------;
  2. ;      MODULE NAME:   EMM25_A.ASM                                             ;
  3. ;                                                                             ;
  4. ;    FUNCTION NAME:   copy_matching_struct_entries                            ;
  5. ;                                                                             ;
  6. ;      DESCRIPTION:   This function copies entries from an array of           ;
  7. ;                     structures (mappable_region_struct[]) which have a      ;
  8. ;                     member (mappable_region_seg) which falls between an     ;
  9. ;                     inclusive lower & upper bound.  Source structure        ;
  10. ;                     entries which qualify are copied into a destination     ;
  11. ;                     array of structures.  A count of the number of entries  ;
  12. ;                     copied is returned.                                     ;
  13. ;                                                                             ;
  14. ;                     This function provides a means of extracting either     ;
  15. ;                     the conventional or expanded memory mappable regions    ;
  16. ;                     ONLY from the total mappable_region_struct structure.   ;
  17. ;                                                                             ;
  18. ;           PASSED:   DS:SI = ptr_source                                      ;
  19. ;                             Pointer to the source mappable_region_struct    ;
  20. ;                             which contains qualified & unqualified members. ;
  21. ;                                                                             ;
  22. ;                     ES:DI = ptr_dest                                        ;
  23. ;                             Pointer to the dest mappable_region_struct      ;
  24. ;                             into which only qualified members will be       ;
  25. ;                             copied.                                         ;
  26. ;                                                                             ;
  27. ;                     AX    = begin_seg                                       ;
  28. ;                             Beginning segment of qualifying members.        ;
  29. ;                                                                             ;
  30. ;                     BX    = end_seg                                         ;
  31. ;                             Ending segment of qualifying members.           ;
  32. ;                                                                             ;
  33. ;                     CX    = source_count                                    ;
  34. ;                             Total number of members in the                  ;
  35. ;                             source mappable_region_struct structure.        ;
  36. ;                                                                             ;
  37. ;         RETURNED:   CX    = dest_count                                      ;
  38. ;                             Number of entries copied into the destination   ;
  39. ;                             structure. An entry is copied from the source   ;
  40. ;                             into the destination structure if:              ;
  41. ;                                                                             ;
  42. ;                             (begin_seg <= mappable_region_seg <= end_seg)   ;
  43. ;                                                                             ;
  44. ;    REGS MODIFIED:   SI   DI   CX                                            ;
  45. ;                                                                             ;
  46. ;   USE CONVENTION:   LDS    SI, ptr_source_mappable_region_struct            ;
  47. ;                     LES    DI, ptr_dest_mappable_region_struct              ;
  48. ;                     MOV    AX, FIRST_EXP_SEG                                ;
  49. ;                     MOV    BX, LAST_EXP_SEG                                 ;
  50. ;                     MOV    CX, source_mappable_region_struct_count          ;
  51. ;                     CALL   copy_matching_struct_entries                     ;
  52. ;                     MOV    dest_mappable_region_struct_count, DX            ;
  53. ;-----------------------------------------------------------------------------;
  54. .XLIST
  55. PAGE    60,132
  56.  
  57. IFDEF SMALL
  58.    .MODEL SMALL, C
  59. ENDIF
  60. IFDEF MEDIUM
  61.    .MODEL MEDIUM, C
  62. ENDIF
  63. IFDEF LARGE
  64.    .MODEL LARGE, C
  65. ENDIF
  66. IFDEF COMPACT
  67.    .MODEL COMPACT, C
  68. ENDIF
  69. IFDEF HUGE
  70.    .MODEL HUGE, C
  71. ENDIF
  72.  
  73. INCLUDE emmlib.equ
  74. INCLUDE emmlib.str
  75. INCLUDE emmlib.mac
  76. .LIST
  77. .CODE
  78.  
  79. copy_matching_struct_entries    PROC
  80.  
  81.     ;---------------------------------------------------------------------;
  82.     ;   do;                                                               ;
  83.     ;   .   move direction is FORWARD;                                    ;
  84.     ;---------------------------------------------------------------------;
  85.     CLD
  86.  
  87.     ;---------------------------------------------------------------------;
  88.     ;   .   dest_count = 0;                                               ;
  89.     ;   .   if (source_count <= MAX_MAPPABLE_REGIONS) do;                 ;
  90.     ;---------------------------------------------------------------------;
  91.     XOR        CH, CH
  92.     CMP        CL, MAX_MAPPABLE_REGIONS
  93.     JA        exit_copy_matching_struct_entries
  94.  
  95.     ;---------------------------------------------------------------------;
  96.     ;   .   .   do while (source_count <> 0);                             ;
  97.     ;   .   .   .   if     ((mappable_region_seg => begin_seg)            ;
  98.     ;   .   .   .   .   and (mappable_region_seg <= end_seg)) do;         ;
  99.     ;---------------------------------------------------------------------;
  100.     JCXZ        exit_copy_matching_struct_entries
  101. begin_copy_matching_struct_entries:
  102.     CMP        [SI].mappable_region_seg, AX
  103.     JB        end_copy_matching_struct_entries
  104.     CMP        [SI].mappable_region_seg, BX
  105.     JA        end_copy_matching_struct_entries
  106.  
  107.     ;---------------------------------------------------------------------;
  108.     ;   .   .   .   .   copy source struc entry to dest struct;           ;
  109.     ;   .   .   .   .   ptr_dest_struct = ptr_dest_struct                 ;
  110.     ;   .   .   .   .                     + dest struct size;             ;
  111.     ;---------------------------------------------------------------------;
  112.     MOVSW
  113.     MOVSW
  114.     SUB        SI, SIZE mappable_region_struct
  115.  
  116.     ;---------------------------------------------------------------------;
  117.     ;   .   .   .   .   dest_count = dest_count + 1;                      ;
  118.     ;   .   .   .   endif  ((mappable_region_seg => begin_seg)            ;
  119.     ;   .   .   .       and (mappable_region_seg <= end_seg));            ;
  120.     ;---------------------------------------------------------------------;
  121.     INC        CH
  122.  
  123. end_copy_matching_struct_entries:
  124.     ;---------------------------------------------------------------------;
  125.     ;   .   .   .   ptr_source = ptr_source + source struct size;         ;
  126.     ;   .   .   .   source_count = source_count - 1;                      ;
  127.     ;   .   .   endwhile (source_count <> 0);                             ;
  128.     ;   .   endif (source_count <= MAX_MAPPABLE_REGIONS);                 ;
  129.     ;---------------------------------------------------------------------;
  130.     ADD        SI, SIZE mappable_region_struct
  131.     DEC        CL
  132.     JNZ        begin_copy_matching_struct_entries
  133.  
  134. exit_copy_matching_struct_entries:
  135.     ;---------------------------------------------------------------------;
  136.     ;   .   return (dest_count);                                          ;
  137.     ;   end;                                                              ;
  138.     ;---------------------------------------------------------------------;
  139.     MOVE        CH:CL, 0:CH
  140.     RET
  141.  
  142. copy_matching_struct_entries    ENDP
  143.  
  144. PAGE
  145. ;-----------------------------------------------------------------------------;
  146. ;      MODULE NAME:   EMM25_A.ASM                                             ;
  147. ;                                                                             ;
  148. ;    FUNCTION NAME:   copy_mappable_regions_struct                            ;
  149. ;                                                                             ;
  150. ;      DESCRIPTION:   This function copies entries from an array of           ;
  151. ;                     structures (mappable_region_struct[]) which have a      ;
  152. ;                     member (mappable_region_seg) which falls between an     ;
  153. ;                     inclusive lower & upper bound.  Source structure        ;
  154. ;                     entries which qualify are copied into a destination     ;
  155. ;                     array of structures.  A count of the number of entries  ;
  156. ;                     copied is returned.                                     ;
  157. ;                                                                             ;
  158. ;                     This function provides a means of extracting either     ;
  159. ;                     the conventional or expanded memory mappable regions    ;
  160. ;                     ONLY from the total mappable_region_struct structure.   ;
  161. ;                                                                             ;
  162. ;           PASSED:   AX    = begin_seg                                       ;
  163. ;                             Beginning segment of qualifying members.        ;
  164. ;                                                                             ;
  165. ;                     BX    = end_seg                                         ;
  166. ;                             Ending segment of qualifying members.           ;
  167. ;                                                                             ;
  168. ;                     DS:SI = ptr_struct                                      ;
  169. ;                             Pointer to the dest mappable_region_struct      ;
  170. ;                             into which only qualified members will be       ;
  171. ;                             copied.  If the pointer is NULL, the structure  ;
  172. ;                             is not copied & discarded.                      ;
  173. ;                                                                             ;
  174. ;         RETURNED:   DX    = struct_count                                    ;
  175. ;                             Number of entries copied into the destination   ;
  176. ;                             structure. An entry is copied from the source   ;
  177. ;                             into the destination structure if:              ;
  178. ;                                                                             ;
  179. ;                             (begin_seg <= mappable_region_seg <= end_seg)   ;
  180. ;                                                                             ;
  181. ;    REGS MODIFIED:   AX   BX   CX   DX   SI   DI   DS   ES                   ;
  182. ;                                                                             ;
  183. ;   USE CONVENTION:   LDS    SI, ptr_dest_mappable_region_struct              ;
  184. ;                     MOV    AX, FIRST_EXP_SEG                                ;
  185. ;                     MOV    BX, LAST_EXP_SEG                                 ;
  186. ;                     CALL   copy_mappable_region_struct                      ;
  187. ;                     MOV    dest_mappable_region_struct_count, DX            ;
  188. ;-----------------------------------------------------------------------------;
  189.  
  190. copy_mappable_regions_struct    PROC
  191.                 LOCAL    begin_seg:WORD,                       \
  192.                     end_seg:WORD
  193.  
  194.     ;---------------------------------------------------------------------;
  195.     ;   do;                                                               ;
  196.     ;   .   move direction is FORWARD;                                    ;
  197.     ;   .   save passed variables on local stack;                         ;
  198.     ;   .   # mappable region struct entries = 0;                         ;
  199.     ;---------------------------------------------------------------------;
  200.     CLD
  201.     MOVE        begin_seg, AX
  202.     MOVE        end_seg,   BX 
  203.     MOVE        DX, 0
  204.  
  205.     ;---------------------------------------------------------------------;
  206.     ;   .   get the size of the mappable region struct from EMM;          ;
  207.     ;---------------------------------------------------------------------;
  208.     MOVE        AX, get_mappable_array_entries_fcn
  209.     INT         EMM_int
  210.  
  211.     ;---------------------------------------------------------------------;
  212.     ;   .   if (EMM status  = passed) do;                                 ;
  213.     ;   .   .   if (# mappable region struct entries <> 0) do;            ;
  214.     ;   .   .   .   if (# mappable region struct entries > MAX valid #) do;
  215.     ;   .   .   .   .   EMM status = s/w error;                           ;
  216.     ;   .   .   .   else do;                                              ;
  217.     ;---------------------------------------------------------------------;
  218.     TEST        AH, AH
  219.     JNZ        end_get_regions
  220.     JCXZ        end_get_regions
  221.     MOVE        AH, software_err_stat
  222.     CMP        CX, MAX_MAPPABLE_REGIONS
  223.     JA        end_get_regions
  224.  
  225.     ;---------------------------------------------------------------------;
  226.     ;   .   .   .   .   allocate mappable region struct on stack;         ;
  227.     ;---------------------------------------------------------------------;
  228.     MULT        CX, <SIZE mappable_region_struct>
  229.     SUB        SP, CX
  230.     MOVE        BX, CX
  231.  
  232.     ;---------------------------------------------------------------------;
  233.     ;   .   .   .   .   get the mappable region struct from EMM;          ;
  234.     ;---------------------------------------------------------------------;
  235.     MOVE        AX, get_mappable_phys_addr_array_fcn
  236.     MOVE        ES:DI, SS:SP
  237.     INT         EMM_int
  238.  
  239.     ;---------------------------------------------------------------------;
  240.     ;   .   .   .   .   if (EMM status = passed) do;                      ;
  241.     ;---------------------------------------------------------------------;
  242.     TEST        AH, AH
  243.     JNZ        continue_get_regions
  244.  
  245.     ;---------------------------------------------------------------------;
  246.     ;   .   .   .   .   .   if (ptr_dest_struct = 0)                      ;
  247.     ;   .   .   .   .   .   .   ptr_dest_struct = ptr_source_struct;      ;
  248.     ;---------------------------------------------------------------------;
  249.     MOVE        ES:DI, DS:SI
  250.     MOVE        DS:SI, SS:SP
  251.     MOVE        AX, ES
  252.     OR        AX, DI
  253.     JNZ        begin_copy_regions
  254.     MOVE        ES:DI, SS:SP
  255.  
  256. begin_copy_regions:
  257.     ;---------------------------------------------------------------------;
  258.     ;   .   .   .   .   .   do while (ptr_source_struct < end of struct); ;
  259.     ;   .   .   .   .   .   .   if ((mappable region seg                  ;
  260.     ;   .   .   .   .   .   .        >= start of specified region)        ;
  261.     ;   .   .   .   .   .   .   and (mappable region seg                  ;
  262.     ;   .   .   .   .   .   .        <= end of specified region)) do;     ;
  263.     ;---------------------------------------------------------------------;
  264.     MOVE        AX, [SI].mappable_region_seg
  265.     CMP        AX, begin_seg
  266.     JB        end_copy_regions
  267.     CMP        AX, end_seg
  268.     JA        end_copy_regions
  269.  
  270.     ;---------------------------------------------------------------------;
  271.     ;   .   .   .   .   .   .   .   copy source structure entry to        ;
  272.     ;   .   .   .   .   .   .   .   destination structure;                ;
  273.     ;   .   .   .   .   .   .   .   ptr_dest_struct = ptr_dest_struct     ;
  274.     ;   .   .   .   .   .   .   .                     + dest struct size; ;
  275.     ;---------------------------------------------------------------------;
  276.     MOVSW
  277.     MOVSW
  278.     SUB        SI, SIZE mappable_region_struct
  279.  
  280.     ;---------------------------------------------------------------------;
  281.     ;   .   .   .   .   .   .   .   # mappable region struct entries =    ;
  282.     ;   .   .   .   .   .   .   .   # mappable region struct entries + 1; ;
  283.     ;---------------------------------------------------------------------;
  284.     INC        DX
  285.  
  286. end_copy_regions:
  287.     ;---------------------------------------------------------------------;
  288.     ;   .   .   .   .   .   .   endif ((mappable region seg               ;
  289.     ;   .   .   .   .   .   .           >= start of specified region)     ;
  290.     ;   .   .   .   .   .   .      and (mappable region seg               ;
  291.     ;   .   .   .   .   .   .           <= end of specified region));     ;
  292.     ;   .   .   .   .   .   .   ptr_source_struct = ptr_source_struct     ;
  293.     ;   .   .   .   .   .   .                       + source struct size; ;
  294.     ;   .   .   .   .   .   end while (ptr_source_struct < end of struct);;
  295.     ;   .   .   .   .   .   EMM status = passed;                          ;
  296.     ;---------------------------------------------------------------------;
  297.     ADD        SI, SIZE mappable_region_struct
  298.     LOOP        begin_copy_regions
  299.     MOVE        AX, fcn_passed_stat
  300.  
  301. continue_get_regions:
  302.     ;---------------------------------------------------------------------;
  303.     ;   .   .   .   .   endif (EMM status = passed);                      ;
  304.     ;   .   .   .   .   deallocate mappable region struct on stack;       ;
  305.     ;---------------------------------------------------------------------;
  306.     ADD        SP, BX
  307.  
  308. end_get_regions:
  309.     ;---------------------------------------------------------------------;
  310.     ;   .   .   .   endif (# mappable region struct entries<=MAX valid #);;
  311.     ;   .   .   endif (# mappable region struct entries <> 0);            ;
  312.     ;   .   endif (EMM status  = passed);                                 ;
  313.     ;   .   return (AH = EMM status, DX = mappable region count);         ;
  314.     ;   end;                                                              ;
  315.     ;---------------------------------------------------------------------;
  316.     RET        
  317.  
  318. copy_mappable_regions_struct    ENDP
  319.  
  320. PAGE
  321. ;-----------------------------------------------------------------------------;
  322. ;      MODULE NAME:   EMM25_A.ASM                                             ;
  323. ;                                                                             ;
  324. ;    FUNCTION NAME:   get_mappable_conv_regions                               ;
  325. ;                                                                             ;
  326. ;      DESCRIPTION:   This function returns an array containing the segment   ;
  327. ;                     address and physical page number for each mappable      ;
  328. ;                     physical page within the conventional memory range      ;
  329. ;                     in a system.  The contents of this array provide a      ;
  330. ;                     cross reference between physical page numbers and the   ;
  331. ;                     actual segment addresses for each mappable page of      ;
  332. ;                     conventional memory in the system.  The array is sorted ;
  333. ;                     in ascending segment order.  This does not mean that    ;
  334. ;                     the physical page numbers associated with the segment   ;
  335. ;                     addresses are also in ascending order.                  ;
  336. ;                                                                             ;
  337. ;           PASSED:   &mcr_count:                                             ;
  338. ;                        is a far pointer to a count of the number of entries ;
  339. ;                        in the mcr array of structures that will be returned ;
  340. ;                        by the function.                                     ;
  341. ;                                                                             ;
  342. ;                     mcr:                                                    ;
  343. ;                        is a far pointer to an application-supplied          ;
  344. ;                        array of structures that will be initialized by the  ;
  345. ;                        function.                                            ;
  346. ;                                                                             ;
  347. ;         RETURNED:   status:                                                 ;
  348. ;                        is the status EMM returns from the call.  All other  ;
  349. ;                        returned results are valid only if the status        ;
  350. ;                        returned is zero.  Otherwise they are undefined.     ;
  351. ;                                                                             ;
  352. ;                     mcr_count:                                              ;
  353. ;                        is a count of the number of entries in the mcr       ;
  354. ;                        array of structures returned by the function.        ;
  355. ;                                                                             ;
  356. ;                     mcr:                                                    ;
  357. ;                        is an application supplied structure that contains   ;
  358. ;                        two elements initialized by the function.  The       ;
  359. ;                        structure members are described here:                ;
  360. ;                                                                             ;
  361. ;                        mcr.mappable_region_seg:                             ;
  362. ;                           is the segment address of the corresponding       ;
  363. ;                           physical page.  The array entries are sorted in   ;
  364. ;                           ascending segment address order.                  ;
  365. ;                                                                             ;
  366. ;                        mcr.phys_page:                                       ;
  367. ;                           is the physical page number of the corresponding  ;
  368. ;                           segment address.  The physical page numbers are   ;
  369. ;                           not in ascending order.                           ;
  370. ;                                                                             ;
  371. ; C USE CONVENTION:   unsigned int           status;                          ;
  372. ;                     unsigned int           mcr_count;                       ;
  373. ;                     MAPPABLE_REGION_STRUCT mcr [MAX_MAPPABLE_REGIONS];      ;
  374. ;                                                                             ;
  375. ;                     status = get_mappable_conv_regions (&mcr_count,         ;
  376. ;                                                         mcr);               ;
  377. ;-----------------------------------------------------------------------------;
  378.  
  379. get_mappable_conv_regions    PROC                                          \
  380.                 USES DS SI DI,                                   \
  381.                 ptr_mappable_conv_reg_count:FAR PTR WORD,         \
  382.                 ptr_mappable_conv_reg_struct:FAR PTR BYTE
  383.  
  384.     ;---------------------------------------------------------------------;
  385.     ;   do;                                                               ;
  386.     ;   .   get the size of the mappable region struct from EMM;          ;
  387.     ;---------------------------------------------------------------------;
  388.     MOVE        AX, get_mappable_array_entries_fcn
  389.     INT         EMM_int
  390.  
  391.     ;---------------------------------------------------------------------;
  392.     ;   .   if (EMM status = passed) do;                                  ;
  393.     ;---------------------------------------------------------------------;
  394.     TEST        AH, AH
  395.     JNZ        end_get_conv_regions
  396.  
  397.     ;---------------------------------------------------------------------;
  398.     ;   .   .   if (# mappable region struct entries > MAX valid #) do;   ;
  399.     ;   .   .   .   EMM status = s/w error;                               ;
  400.     ;   .   .   else do;                                                  ;
  401.     ;---------------------------------------------------------------------;
  402.     CMP        CX, MAX_MAPPABLE_REGIONS
  403.     JBE        begin_get_conv_regions
  404.     MOVE        AH, software_err_stat
  405.     JMP        end_get_conv_regions
  406.  
  407. begin_get_conv_regions:
  408.     ;---------------------------------------------------------------------;
  409.     ;   .   .   .   if (# mappable region struct entries <> 0) do;        ;
  410.     ;---------------------------------------------------------------------;
  411.     JCXZ        end_get_conv_regions
  412.  
  413.     ;---------------------------------------------------------------------;
  414.     ;   .   .   .   .   allocate mappable region struct on stack;         ;
  415.     ;---------------------------------------------------------------------;
  416.     MOVE        DX, CX
  417.     MULT        DX, <SIZE mappable_region_struct>
  418.     SUB        SP, DX
  419.  
  420.     ;---------------------------------------------------------------------;
  421.     ;   .   .   .   .   get the mappable region struct from EMM;          ;
  422.     ;---------------------------------------------------------------------;
  423.     MOVE        AX, get_mappable_phys_addr_array_fcn
  424.     MOVE        ES:DI, SS:SP
  425.     INT         EMM_int
  426.  
  427.     ;---------------------------------------------------------------------;
  428.     ;   .   .   .   .   if (EMM status = passed) do;                      ;
  429.     ;---------------------------------------------------------------------;
  430.     TEST        AH, AH
  431.     JNZ        continue_get_conv_regions
  432.  
  433.     ;---------------------------------------------------------------------;
  434.     ;   .   .   .   .   .   pass mappable conv region struct back         ;
  435.     ;                       to caller;                                    ;
  436.     ;---------------------------------------------------------------------;
  437.     MOVE        DS:SI, SS:SP
  438.     MOVE        ES:DI, ptr_mappable_conv_reg_struct
  439.     PUSH        AX
  440.     MOVE        AX:BX, FIRST_CONV_SEG:LAST_CONV_SEG
  441.     CALL        copy_matching_struct_entries
  442.     POP        AX
  443.  
  444.     ;---------------------------------------------------------------------;
  445.     ;   .   .   .   .   .   pass the # mappable conv regions back         ;
  446.     ;                       to caller;                                    ;
  447.     ;---------------------------------------------------------------------;
  448.     MOVE        ES:BX, ptr_mappable_conv_reg_count
  449.     MOVE        ES:[BX], CX
  450.  
  451. continue_get_conv_regions:
  452.     ;---------------------------------------------------------------------;
  453.     ;   .   .   .   .   end if (EMM status = passed);                     ;
  454.     ;   .   .   .   .   deallocate mappable region struct on stack;       ;
  455.     ;---------------------------------------------------------------------;
  456.     ADD        SP, DX
  457.  
  458. end_get_conv_regions:
  459.     ;---------------------------------------------------------------------;
  460.     ;   .   .   .   end if (# mappable region struct entries <> 0);       ;
  461.     ;   .   .   end if (# mappable region array entries <= MAX valid #);  ;
  462.     ;   .   end if (EMM status  = passed);                                ;
  463.     ;   .   return (EMM status);                                          ;
  464.     ;   end;                                                              ;
  465.     ;---------------------------------------------------------------------;
  466.     RET_EMM_STAT    AH
  467.  
  468. get_mappable_conv_regions    ENDP
  469.  
  470. PAGE
  471. ;-----------------------------------------------------------------------------;
  472. ;      MODULE NAME:   EMM25_A.ASM                                             ;
  473. ;                                                                             ;
  474. ;    FUNCTION NAME:   get_mappable_exp_regions                                ;
  475. ;                                                                             ;
  476. ;      DESCRIPTION:   This function returns an array containing the segment   ;
  477. ;                     address and physical page number for each mappable      ;
  478. ;                     physical page within the expanded memory range          ;
  479. ;                     in a system.  The contents of this array provide a      ;
  480. ;                     cross reference between physical page numbers and the   ;
  481. ;                     actual segment addresses for each mappable page of      ;
  482. ;                     expanded memory in the system.  The array is sorted     ;
  483. ;                     in ascending segment order.  This does not mean that    ;
  484. ;                     the physical page numbers associated with the segment   ;
  485. ;                     addresses are also in ascending order.                  ;
  486. ;                                                                             ;
  487. ;           PASSED:   &mer_count:                                             ;
  488. ;                        is a far pointer to a count of the number of entries ;
  489. ;                        in the mer array of structures that will be returned ;
  490. ;                        by the function.                                     ;
  491. ;                                                                             ;
  492. ;                     mer:                                                    ;
  493. ;                        is a far pointer to an application-supplied          ;
  494. ;                        array of structures that will be initialized by the  ;
  495. ;                        function.                                            ;
  496. ;                                                                             ;
  497. ;         RETURNED:   status:                                                 ;
  498. ;                        is the status EMM returns from the call.  All other  ;
  499. ;                        returned results are valid only if the status        ;
  500. ;                        returned is zero.  Otherwise they are undefined.     ;
  501. ;                                                                             ;
  502. ;                     mer_count:                                              ;
  503. ;                        is a count of the number of entries in the mer       ;
  504. ;                        array of structures returned by the function.        ;
  505. ;                                                                             ;
  506. ;                     mer:                                                    ;
  507. ;                        is an application supplied structure that contains   ;
  508. ;                        two elements initialized by the function.  The       ;
  509. ;                        structure members are described here:                ;
  510. ;                                                                             ;
  511. ;                        mer.mappable_region_seg:                             ;
  512. ;                           is the segment address of the corresponding       ;
  513. ;                           physical page.  The array entries are sorted in   ;
  514. ;                           ascending segment address order.                  ;
  515. ;                                                                             ;
  516. ;                        mer.phys_page:                                       ;
  517. ;                           is the physical page number of the corresponding  ;
  518. ;                           segment address.  The physical page numbers are   ;
  519. ;                           not in ascending order.                           ;
  520. ;                                                                             ;
  521. ; C USE CONVENTION:   unsigned int           status;                          ;
  522. ;                     unsigned int           mer_count;                       ;
  523. ;                     MAPPABLE_REGION_STRUCT mer [MAX_MAPPABLE_REGIONS];      ;
  524. ;                                                                             ;
  525. ;                     status = get_mappable_exp_regions (&mer_count,          ;
  526. ;                                                        mer);                ;
  527. ;-----------------------------------------------------------------------------;
  528.  
  529. get_mappable_exp_regions    PROC                                          \
  530.                 USES DS SI DI,                                \
  531.                 ptr_mappable_exp_region_count:FAR PTR WORD,       \
  532.                 ptr_mappable_exp_region_struct:FAR PTR BYTE
  533.  
  534.     ;---------------------------------------------------------------------;
  535.     ;   do;                                                               ;
  536.     ;   .   get the size of the mappable region struct from EMM;          ;
  537.     ;---------------------------------------------------------------------;
  538.     MOVE        AX, get_mappable_array_entries_fcn
  539.     INT         EMM_int
  540.  
  541.     ;---------------------------------------------------------------------;
  542.     ;   .   if (EMM status = passed) do;                                  ;
  543.     ;---------------------------------------------------------------------;
  544.     TEST        AH, AH
  545.     JNZ        end_get_exp_regions
  546.  
  547.     ;---------------------------------------------------------------------;
  548.     ;   .   .   if (# mappable region struct entries > MAX valid #) do;   ;
  549.     ;   .   .   .   EMM status = s/w error;                               ;
  550.     ;   .   .   else do;                                                  ;
  551.     ;---------------------------------------------------------------------;
  552.     CMP        CX, MAX_MAPPABLE_REGIONS
  553.     JBE        begin_get_exp_regions
  554.     MOVE        AH, software_err_stat
  555.     JMP        end_get_exp_regions
  556.  
  557. begin_get_exp_regions:
  558.     ;---------------------------------------------------------------------;
  559.     ;   .   .   .   if (# mappable region struct entries <> 0) do;        ;
  560.     ;---------------------------------------------------------------------;
  561.     JCXZ        end_get_exp_regions
  562.  
  563.     ;---------------------------------------------------------------------;
  564.     ;   .   .   .   .   allocate mappable region struct on stack;         ;
  565.     ;---------------------------------------------------------------------;
  566.     MOVE        DX, CX
  567.     MULT        DX, <SIZE mappable_region_struct>
  568.     SUB        SP, DX
  569.  
  570.     ;---------------------------------------------------------------------;
  571.     ;   .   .   .   .   get the mappable region struct from EMM;          ;
  572.     ;---------------------------------------------------------------------;
  573.     MOVE        AX, get_mappable_phys_addr_array_fcn
  574.     MOVE        ES:DI, SS:SP
  575.     INT         EMM_int
  576.  
  577.     ;---------------------------------------------------------------------;
  578.     ;   .   .   .   .   if (EMM status = passed) do;                      ;
  579.     ;---------------------------------------------------------------------;
  580.     TEST        AH, AH
  581.     JNZ        continue_get_exp_regions
  582.  
  583.     ;---------------------------------------------------------------------;
  584.     ;   .   .   .   .   .   pass mappable exp region struct back          ;
  585.     ;                       to caller;                                    ;
  586.     ;---------------------------------------------------------------------;
  587.     MOVE        DS:SI, SS:SP
  588.     MOVE        ES:DI, ptr_mappable_exp_region_struct
  589.     PUSH        AX
  590.     MOVE        AX:BX, FIRST_EXP_SEG:LAST_EXP_SEG
  591.     CALL        copy_matching_struct_entries
  592.     POP        AX
  593.  
  594.     ;---------------------------------------------------------------------;
  595.     ;   .   .   .   .   .   pass the # mappable exp regions back          ;
  596.     ;                       to caller;                                    ;
  597.     ;---------------------------------------------------------------------;
  598.     MOVE        ES:BX, ptr_mappable_exp_region_count
  599.     MOVE        ES:[BX], CX
  600.  
  601. continue_get_exp_regions:
  602.     ;---------------------------------------------------------------------;
  603.     ;   .   .   .   .   end if (EMM status = passed);                     ;
  604.     ;   .   .   .   .   deallocate mappable region struct on stack;       ;
  605.     ;---------------------------------------------------------------------;
  606.     ADD        SP, DX
  607.  
  608. end_get_exp_regions:
  609.     ;---------------------------------------------------------------------;
  610.     ;   .   .   .   end if (# mappable region struct entries <> 0);       ;
  611.     ;   .   .   end if (# mappable region array entries <= MAX valid #);  ;
  612.     ;   .   end if (EMM status  = passed);                                ;
  613.     ;   .   return (EMM status);                                          ;
  614.     ;   end;                                                              ;
  615.     ;---------------------------------------------------------------------;
  616.     RET_EMM_STAT    AH
  617.  
  618. get_mappable_exp_regions    ENDP
  619.  
  620. PAGE
  621. ;-----------------------------------------------------------------------------;
  622. ;      MODULE NAME:   EMM25_A.ASM                                             ;
  623. ;                                                                             ;
  624. ;    FUNCTION NAME:   get_mappable_conv_region_count                          ;
  625. ;                                                                             ;
  626. ;      DESCRIPTION:   This function gets the number of entries which will be  ;
  627. ;                     required for the array of structures the                ;
  628. ;                     get_mappable_conv_regions function returns.  Note that  ;
  629. ;                     this function does not actually return the array but    ;
  630. ;                     merely a count of the entries in the array returned     ;
  631. ;                     by the get_mappable_conv_regions function.  This        ;
  632. ;                     number also represents the total number of mappable     ;
  633. ;                     conventional memory pages in the system.                ;
  634. ;                                                                             ;
  635. ;           PASSED:   &mcr_count:                                             ;
  636. ;                        is a far pointer to a count of the number of entries ;
  637. ;                        in the array of structures that are returned by the  ;
  638. ;                        get_mappable_conv_regions function.                  ;
  639. ;                                                                             ;
  640. ;         RETURNED:   status:                                                 ;
  641. ;                        is the status EMM returns from the call.  All other  ;
  642. ;                        returned results are valid only if the status        ;
  643. ;                        returned is zero.  Otherwise they are undefined.     ;
  644. ;                                                                             ;
  645. ;                     mcr_count:                                              ;
  646. ;                        is a count of the number of entries in the mcr       ;
  647. ;                        array of structures returned by the                  ;
  648. ;                        get_mappable_conv_regions function.                  ;
  649. ;                                                                             ;
  650. ; C USE CONVENTION:   unsigned int status;                                    ;
  651. ;                     unsigned int mcr_count;                                 ;
  652. ;                                                                             ;
  653. ;                     status = get_mappable_conv_region_count (&mcr_count);   ;
  654. ;-----------------------------------------------------------------------------;
  655.  
  656. get_mappable_conv_region_count    PROC                                          \
  657.                 USES DS SI DI,                                \
  658.                 ptr_mappable_conv_region_count:FAR PTR WORD
  659.  
  660.     ;---------------------------------------------------------------------;
  661.     ;   do;                                                               ;
  662.     ;   .   get the size of the mappable region struct from EMM;          ;
  663.     ;---------------------------------------------------------------------;
  664.     MOVE        AX, get_mappable_array_entries_fcn
  665.     INT         EMM_int
  666.  
  667.     ;---------------------------------------------------------------------;
  668.     ;   .   if (EMM status = passed) do;                                  ;
  669.     ;---------------------------------------------------------------------;
  670.     TEST        AH, AH
  671.     JNZ        end_get_conv_regions_count
  672.  
  673.     ;---------------------------------------------------------------------;
  674.     ;   .   .   if (# mappable region struct entries > MAX valid #) do;   ;
  675.     ;   .   .   .   EMM status = s/w error;                               ;
  676.     ;   .   .   else do;                                                  ;
  677.     ;---------------------------------------------------------------------;
  678.     CMP        CX, MAX_MAPPABLE_REGIONS
  679.     JBE        begin_get_conv_regions_count
  680.     MOVE        AH, software_err_stat
  681.     JMP        end_get_conv_regions_count
  682.  
  683. begin_get_conv_regions_count:
  684.     ;---------------------------------------------------------------------;
  685.     ;   .   .   .   if (# mappable region struct entries <> 0) do;        ;
  686.     ;---------------------------------------------------------------------;
  687.     JCXZ        end_get_conv_regions_count
  688.  
  689.     ;---------------------------------------------------------------------;
  690.     ;   .   .   .   .   allocate mappable region struct on stack;         ;
  691.     ;---------------------------------------------------------------------;
  692.     MOVE        DX, CX
  693.     MULT        DX, <SIZE mappable_region_struct>
  694.     SUB        SP, DX
  695.  
  696.     ;---------------------------------------------------------------------;
  697.     ;   .   .   .   .   get the mappable region struct from EMM;          ;
  698.     ;---------------------------------------------------------------------;
  699.     MOVE        AX, get_mappable_phys_addr_array_fcn
  700.     MOVE        ES:DI, SS:SP
  701.     INT         EMM_int
  702.  
  703.     ;---------------------------------------------------------------------;
  704.     ;   .   .   .   .   if (EMM status = passed) do;                      ;
  705.     ;---------------------------------------------------------------------;
  706.     TEST        AH, AH
  707.     JNZ        continue_get_conv_regions_count
  708.  
  709.     ;---------------------------------------------------------------------;
  710.     ;   .   .   .   .   .   count the # of mappable conv regions;         ;
  711.     ;---------------------------------------------------------------------;
  712.     MOVE        DS:SI, SS:SP
  713.     MOVE        ES:DI, SS:SP
  714.     PUSH        AX
  715.     MOVE        AX:BX, FIRST_CONV_SEG:LAST_CONV_SEG
  716.     CALL        copy_matching_struct_entries
  717.     POP        AX
  718.  
  719.     ;---------------------------------------------------------------------;
  720.     ;   .   .   .   .   .   pass the # mappable conv regions back         ;
  721.     ;                       to caller;                                    ;
  722.     ;---------------------------------------------------------------------;
  723.     MOVE        ES:BX, ptr_mappable_conv_region_count
  724.     MOVE        ES:[BX], CX
  725.  
  726. continue_get_conv_regions_count:
  727.     ;---------------------------------------------------------------------;
  728.     ;   .   .   .   .   end if (EMM status = passed);                     ;
  729.     ;   .   .   .   .   deallocate mappable region struct on stack;       ;
  730.     ;---------------------------------------------------------------------;
  731.     ADD        SP, DX
  732.  
  733. end_get_conv_regions_count:
  734.     ;---------------------------------------------------------------------;
  735.     ;   .   .   .   end if (# mappable region struct entries <> 0);       ;
  736.     ;   .   .   end if (# mappable region array entries <= MAX valid #);  ;
  737.     ;   .   end if (EMM status  = passed);                                ;
  738.     ;   .   return (EMM status);                                          ;
  739.     ;   end;                                                              ;
  740.     ;---------------------------------------------------------------------;
  741.     RET_EMM_STAT    AH
  742.  
  743. get_mappable_conv_region_count    ENDP
  744.  
  745. PAGE
  746. ;-----------------------------------------------------------------------------;
  747. ;      MODULE NAME:   EMM25_A.ASM                                             ;
  748. ;                                                                             ;
  749. ;    FUNCTION NAME:   get_mappable_exp_region_count                           ;
  750. ;                                                                             ;
  751. ;      DESCRIPTION:   This function gets the number of entries which will be  ;
  752. ;                     required for the array of structures the                ;
  753. ;                     get_mappable_exp_regions function returns.  Note that   ;
  754. ;                     this function does not actually return the array but    ;
  755. ;                     merely a count of the entries in the array returned     ;
  756. ;                     by the get_mappable_exp_regions function.  This number  ;
  757. ;                     also represents the total number of mappable expanded   ;
  758. ;                     memory pages in the system.                             ;
  759. ;                                                                             ;
  760. ;           PASSED:   &mer_count:                                             ;
  761. ;                        is a far pointer to a count of the number of entries ;
  762. ;                        in the array of structures that are returned by the  ;
  763. ;                        get_mappable_exp_regions function.                   ;
  764. ;                                                                             ;
  765. ;         RETURNED:   status:                                                 ;
  766. ;                        is the status EMM returns from the call.  All other  ;
  767. ;                        returned results are valid only if the status        ;
  768. ;                        returned is zero.  Otherwise they are undefined.     ;
  769. ;                                                                             ;
  770. ;                     mer_count:                                              ;
  771. ;                        is a count of the number of entries in the mer       ;
  772. ;                        array of structures returned by the                  ;
  773. ;                        get_mappable_exp_regions function.                   ;
  774. ;                                                                             ;
  775. ; C USE CONVENTION:   unsigned int status;                                    ;
  776. ;                     unsigned int mer_count;                                 ;
  777. ;                                                                             ;
  778. ;                     status = get_mappable_exp_region_count (&mer_count);    ;
  779. ;-----------------------------------------------------------------------------;
  780.  
  781. get_mappable_exp_region_count    PROC                                          \
  782.                 USES DS SI DI,                                \
  783.                 ptr_mappable_exp_region_count:FAR PTR WORD
  784.  
  785.     ;---------------------------------------------------------------------;
  786.     ;   do;                                                               ;
  787.     ;   .   get the size of the mappable region struct from EMM;          ;
  788.     ;---------------------------------------------------------------------;
  789.     MOVE        AX, get_mappable_array_entries_fcn
  790.     INT         EMM_int
  791.  
  792.     ;---------------------------------------------------------------------;
  793.     ;   .   if (EMM status = passed) do;                                  ;
  794.     ;---------------------------------------------------------------------;
  795.     TEST        AH, AH
  796.     JNZ        end_get_exp_regions_count
  797.  
  798.     ;---------------------------------------------------------------------;
  799.     ;   .   .   if (# mappable region struct entries > MAX valid #) do;   ;
  800.     ;   .   .   .   EMM status = s/w error;                               ;
  801.     ;   .   .   else do;                                                  ;
  802.     ;---------------------------------------------------------------------;
  803.     CMP        CX, MAX_MAPPABLE_REGIONS
  804.     JBE        begin_get_exp_regions_count
  805.     MOVE        AH, software_err_stat
  806.     JMP        end_get_exp_regions_count
  807.  
  808. begin_get_exp_regions_count:
  809.     ;---------------------------------------------------------------------;
  810.     ;   .   .   .   if (# mappable region struct entries <> 0) do;        ;
  811.     ;---------------------------------------------------------------------;
  812.     JCXZ        end_get_exp_regions_count
  813.  
  814.     ;---------------------------------------------------------------------;
  815.     ;   .   .   .   .   allocate mappable region struct on stack;         ;
  816.     ;---------------------------------------------------------------------;
  817.     MOVE        DX, CX
  818.     MULT        DX, <SIZE mappable_region_struct>
  819.     SUB        SP, DX
  820.  
  821.     ;---------------------------------------------------------------------;
  822.     ;   .   .   .   .   get the mappable region struct from EMM;          ;
  823.     ;---------------------------------------------------------------------;
  824.     MOVE        AX, get_mappable_phys_addr_array_fcn
  825.     MOVE        ES:DI, SS:SP
  826.     INT         EMM_int
  827.  
  828.     ;---------------------------------------------------------------------;
  829.     ;   .   .   .   .   if (EMM status = passed) do;                      ;
  830.     ;---------------------------------------------------------------------;
  831.     TEST        AH, AH
  832.     JNZ        continue_get_exp_regions_count
  833.  
  834.     ;---------------------------------------------------------------------;
  835.     ;   .   .   .   .   .   count the # of mappable exp regions;          ;
  836.     ;---------------------------------------------------------------------;
  837.     MOVE        DS:SI, SS:SP
  838.     MOVE        ES:DI, SS:SP
  839.     PUSH        AX
  840.     MOVE        AX:BX, FIRST_EXP_SEG:LAST_EXP_SEG
  841.     CALL        copy_matching_struct_entries
  842.     POP        AX
  843.  
  844.     ;---------------------------------------------------------------------;
  845.     ;   .   .   .   .   .   pass the # mappable exp regions back          ;
  846.     ;                       to caller;                                    ;
  847.     ;---------------------------------------------------------------------;
  848.     MOVE        ES:BX, ptr_mappable_exp_region_count
  849.     MOVE        ES:[BX], CX
  850.  
  851. continue_get_exp_regions_count:
  852.     ;---------------------------------------------------------------------;
  853.     ;   .   .   .   .   end if (EMM status = passed);                     ;
  854.     ;   .   .   .   .   deallocate mappable region struct on stack;       ;
  855.     ;---------------------------------------------------------------------;
  856.     ADD        SP, DX
  857.  
  858. end_get_exp_regions_count:
  859.     ;---------------------------------------------------------------------;
  860.     ;   .   .   .   end if (# mappable region struct entries <> 0);       ;
  861.     ;   .   .   end if (# mappable region array entries <= MAX valid #);  ;
  862.     ;   .   end if (EMM status  = passed);                                ;
  863.     ;   .   return (EMM status);                                          ;
  864.     ;   end;                                                              ;
  865.     ;---------------------------------------------------------------------;
  866.     RET_EMM_STAT    AH
  867.  
  868. get_mappable_exp_region_count    ENDP
  869.  
  870. PAGE
  871. ;-----------------------------------------------------------------------------;
  872. ;      MODULE NAME:   EMM25_A.ASM                                             ;
  873. ;                                                                             ;
  874. ;    FUNCTION NAME:   get_page_frame_count                                    ;
  875. ;                                                                             ;
  876. ;      DESCRIPTION:   This function returns the number of contiguous pages    ;
  877. ;                     that make up the EMM page frame.                        ;
  878. ;                                                                             ;
  879. ;           PASSED:   &pf_count:                                              ;
  880. ;                        is a far pointer to a count of the contiguous number ;
  881. ;                        of entries which make up the page frame in the array ;
  882. ;                        of structures that are returned by the               ;
  883. ;                        get_mappable_exp_regions function.  This number does ;
  884. ;                        not represent the total number of mappable expanded  ;
  885. ;                        regions, just the contiguous pages that make up the  ;
  886. ;                        page frame.                                          ;
  887. ;                                                                             ;
  888. ;         RETURNED:   status:                                                 ;
  889. ;                        is the status EMM returns from the call.  All other  ;
  890. ;                        returned results are valid only if the status        ;
  891. ;                        returned is zero.  Otherwise they are undefined.     ;
  892. ;                                                                             ;
  893. ;                     pf_count:                                               ;
  894. ;                        is a count of the number of entries that represent   ;
  895. ;                        the page frame in the mer array of structures        ;
  896. ;                        returned by the get_mappable_exp_regions function.   ;
  897. ;                                                                             ;
  898. ; C USE CONVENTION:   unsigned int status;                                    ;
  899. ;                     unsigned int pf_count;                                  ;
  900. ;                                                                             ;
  901. ;                     status = get_page_frame_count (&pf_count);              ;
  902. ;-----------------------------------------------------------------------------;
  903.  
  904. get_page_frame_count             PROC                                          \
  905.                 USES DS SI DI,                                \
  906.                 ptr_page_frame_count:FAR PTR WORD
  907.  
  908.     ;---------------------------------------------------------------------;
  909.     ;   do;                                                               ;
  910.     ;   .   get the size of the mappable region struct from EMM;          ;
  911.     ;---------------------------------------------------------------------;
  912.     MOVE        AX, get_mappable_array_entries_fcn
  913.     INT         EMM_int
  914.  
  915.     ;---------------------------------------------------------------------;
  916.     ;   .   if (EMM status = passed) do;                                  ;
  917.     ;---------------------------------------------------------------------;
  918.     TEST        AH, AH
  919.     JNZ        end_get_page_frame_count
  920.  
  921.     ;---------------------------------------------------------------------;
  922.     ;   .   .   if (# mappable region struct entries > MAX valid #) do;   ;
  923.     ;   .   .   .   EMM status = s/w error;                               ;
  924.     ;   .   .   else do;                                                  ;
  925.     ;---------------------------------------------------------------------;
  926.     CMP        CX, MAX_MAPPABLE_REGIONS
  927.     JBE        begin_get_page_frame_count
  928.     MOVE        AH, software_err_stat
  929.     JMP        end_get_page_frame_count
  930.  
  931. begin_get_page_frame_count:
  932.     ;---------------------------------------------------------------------;
  933.     ;   .   .   .   if (# mappable region struct entries <> 0) do;        ;
  934.     ;---------------------------------------------------------------------;
  935.     JCXZ        end_get_page_frame_count
  936.  
  937.     ;---------------------------------------------------------------------;
  938.     ;   .   .   .   .   allocate mappable region struct on stack;         ;
  939.     ;---------------------------------------------------------------------;
  940.     MOVE        DX, CX
  941.     MULT        DX, <SIZE mappable_region_struct>
  942.     SUB        SP, DX
  943.  
  944.     ;---------------------------------------------------------------------;
  945.     ;   .   .   .   .   get the mappable region struct from EMM;          ;
  946.     ;---------------------------------------------------------------------;
  947.     MOVE        AX, get_mappable_phys_addr_array_fcn
  948.     MOVE        ES:DI, SS:SP
  949.     INT         EMM_int
  950.  
  951.     ;---------------------------------------------------------------------;
  952.     ;   .   .   .   .   if (EMM status = passed) do;                      ;
  953.     ;---------------------------------------------------------------------;
  954.     TEST        AH, AH
  955.     JNZ        continue_get_page_frame_count
  956.  
  957.     ;---------------------------------------------------------------------;
  958.     ;   .   .   .   .   .   count the # of pages in the page frame;       ;
  959.     ;---------------------------------------------------------------------;
  960.     MOVE        DS:SI, SS:SP
  961.     PUSH        AX
  962.         PUSH            DX
  963.         
  964.     ;---------------------------------------------------------------------;
  965.     ;   .   .   .   .   .   get page frame segment from EMM;              ;
  966.     ;---------------------------------------------------------------------;
  967.     MOVE        AH, get_page_frame_fcn
  968.     INT         EMM_int
  969.  
  970.         ;---------------------------------------------------------------------;
  971.         ;   .   .   .   .   .   if (EMM status = passed) do;                  ;
  972.         ;---------------------------------------------------------------------;
  973.         TEST            AH, AH
  974.         JNZ             continue_get_page_frame_count        
  975.  
  976.     ;---------------------------------------------------------------------;
  977.     ;   .   .   .   .   .   Save the last valid index;                    ;
  978.     ;---------------------------------------------------------------------;
  979.         MOVE            DI, CX
  980.     MULT        DI, <SIZE mappable_region_struct>
  981.         ADD             DI, SI
  982.         XOR             CX, CX
  983.  
  984.     ;---------------------------------------------------------------------;
  985.     ;   .   .   .   .   .   See if current segment is the page frame seg; ;
  986.     ;---------------------------------------------------------------------;
  987. check_for_page_frame_seg:
  988.         MOVE            AX, [SI]
  989.         ADD             SI, 4
  990.         CMP             AX, BX
  991.         JNE             check_for_page_frame_seg
  992.  
  993.     ;---------------------------------------------------------------------;
  994.     ;   .   .   .   .   .   We have found the page frame;                 ;
  995.     ;---------------------------------------------------------------------;
  996. check_next_seg_in_page_frame:
  997.         INC             CX
  998.  
  999.     ;---------------------------------------------------------------------;
  1000.     ;   .   .   .   .   .   have we exhausted the array?;                 ;
  1001.     ;---------------------------------------------------------------------;
  1002.         CMP             SI, DI
  1003.         JAE             return_page_frame_count
  1004.  
  1005.     ;---------------------------------------------------------------------;
  1006.     ;   .   .   .   .   .   See if next segment is contiguous;            ;
  1007.     ;---------------------------------------------------------------------;
  1008.         ADD             AX, 0400H
  1009.         MOVE            DX, AX
  1010.         MOVE            AX, [SI]
  1011.         ADD             SI, 4
  1012.         CMP             AX, DX
  1013.         JE              check_next_seg_in_page_frame
  1014.  
  1015. return_page_frame_count:
  1016.         POP             DX
  1017.     POP        AX
  1018.  
  1019.     ;---------------------------------------------------------------------;
  1020.     ;   .   .   .   .   .   pass the page frame count back to caller;     ;
  1021.     ;---------------------------------------------------------------------;
  1022.     MOVE        ES:BX, ptr_page_frame_count
  1023.     MOVE        ES:[BX], CX
  1024.  
  1025. continue_get_page_frame_count:
  1026.     ;---------------------------------------------------------------------;
  1027.     ;   .   .   .   .   end if (EMM status = passed);                     ;
  1028.     ;   .   .   .   .   deallocate mappable region struct on stack;       ;
  1029.     ;---------------------------------------------------------------------;
  1030.     ADD        SP, DX
  1031.  
  1032. end_get_page_frame_count:
  1033.     ;---------------------------------------------------------------------;
  1034.     ;   .   .   .   end if (# mappable region struct entries <> 0);       ;
  1035.     ;   .   .   end if (# mappable region array entries <= MAX valid #);  ;
  1036.     ;   .   end if (EMM status  = passed);                                ;
  1037.     ;   .   return (EMM status);                                          ;
  1038.     ;   end;                                                              ;
  1039.     ;---------------------------------------------------------------------;
  1040.     RET_EMM_STAT    AH
  1041.  
  1042. get_page_frame_count    ENDP
  1043.  
  1044.  
  1045. PAGE
  1046. ;-----------------------------------------------------------------------------;
  1047. ;                STACK SPACE REQUIRED BY THE INTERFACE LIBRARY                ;
  1048. ;-----------------------------------------------------------------------------;
  1049.  
  1050. .STACK (2 * MAX_MAPPABLE_REGIONS * (SIZE mappable_region_struct))
  1051.  
  1052. END
  1053.